package com.example.fist.dao;


import com.example.fist.entity.CodeEntity;
import com.example.fist.personRepository.AdminJpaRepository;
import com.example.fist.personRepository.CodeJpaRepository;
import org.springframework.beans.factory.annotation.Autowired;

import javax.persistence.EntityManager;
import java.util.Date;

public class CodeDao {
    @Autowired
    private CodeJpaRepository codeRepository;



    @Autowired
    private EntityManager entityManager;



    public CodeDao(CodeJpaRepository codeRepository,EntityManager entityManager){

        this.codeRepository=codeRepository;
        this.entityManager=entityManager;
    }
    public int save( CodeEntity code) {

          codeRepository.save(code);
        return 1;

    }
    public  CodeEntity getCodeId(int id,String code){
        CodeEntity codeEntity=codeRepository.getCode(id,code);
        return  codeEntity;
    }
    public  CodeEntity update( CodeEntity code){
        CodeEntity entity = codeRepository.save(code);
        return  entity;
    }
}
